package com.chentongwei.biz;

import com.chentongwei.entity.Properties;
import com.chentongwei.util.PropertiesUtil;

/**
 * @author TongWei.Chen 2018-03-06 13:07
 * @Description：配置类业务处理
 */
public class PropertiesBiz {

    private static final String CONFIG_NAME = "system.properties";
    private static final String EXCEPTION_HANDLER_TYPE_PREFFIX = "com.chentongwei.exception.handler.type";
    private static final String EXCEPTION_VIEW_PREFFIX = "com.chentongwei.exception.view";

    private static String exceptionHandlerType;
    private static String exceptionView;

    static {
        PropertiesUtil propertiesUtil = new PropertiesUtil(CONFIG_NAME);
        exceptionHandlerType = propertiesUtil.readProperty(EXCEPTION_HANDLER_TYPE_PREFFIX);
        exceptionView = propertiesUtil.readProperty(EXCEPTION_VIEW_PREFFIX);
    }

    public static String getExceptionView() {
        return exceptionView;
    }

    public static Properties getProperties() {
        Properties properties = new Properties();

        if (null != exceptionHandlerType && exceptionHandlerType != "") {
            properties.setExceptionHandlerType(exceptionHandlerType);
        }
        return properties;
    }

}
